/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.mailbox.Color;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.mailbox.Flag;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.mailbox.SearchFolder;
/*    */ import com.zimbra.cs.service.util.ItemId;
/*    */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateSearchFolder
/*    */   extends MailDocumentHandler
/*    */ {
/* 39 */   private static final String[] TARGET_FOLDER_PATH = { "search", "l" };
/* 40 */   private static final String[] RESPONSE_ITEM_PATH = new String[0];
/*    */   
/*    */   protected String[] getProxiedIdPath(Element request)
/*    */   {
/* 44 */     return TARGET_FOLDER_PATH;
/*    */   }
/*    */   
/*    */   protected boolean checkMountpointProxy(Element request)
/*    */   {
/* 49 */     return true;
/*    */   }
/*    */   
/*    */   protected String[] getResponseItemPath()
/*    */   {
/* 54 */     return RESPONSE_ITEM_PATH;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 59 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 60 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 61 */     OperationContext octxt = getOperationContext(zsc, context);
/* 62 */     ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
/*    */     
/* 64 */     Element t = request.getElement("search");
/* 65 */     String name = t.getAttribute("name");
/* 66 */     String query = t.getAttribute("query");
/* 67 */     String types = t.getAttribute("types", null);
/* 68 */     String sort = t.getAttribute("sortBy", null);
/* 69 */     String flags = t.getAttribute("f", null);
/* 70 */     byte color = (byte)(int)t.getAttributeLong("color", 0L);
/* 71 */     String rgb = t.getAttribute("rgb", null);
/*    */     
/* 73 */     Color itemColor = rgb != null ? new Color(rgb) : new Color(color);
/* 74 */     ItemId iidParent = new ItemId(t.getAttribute("l"), zsc);
/*    */     
/* 76 */     SearchFolder search = mbox.createSearchFolder(octxt, iidParent.getId(), name, query, types, sort, Flag.toBitmask(flags), itemColor);
/*    */     
/*    */ 
/* 79 */     Element response = zsc.createElement(MailConstants.CREATE_SEARCH_FOLDER_RESPONSE);
/* 80 */     if (search != null)
/* 81 */       ToXML.encodeSearchFolder(response, ifmt, search);
/* 82 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/CreateSearchFolder.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */